<template>
	<div style='height:100%;'>
		<v-chart v-if='value' style='height: 100%;width: 100%;' :options='options'></v-chart>
		<loading v-else></loading>
	</div>
</template>

<script>
	export default {
		props : {
			value : {
				type : [Array, Object],
				default : function() {
					return []
				}
			}
		},
		
		data() {
			return {
			
			}
		},
		
		computed : {
			options () {
                var xAxisData = this.value.date //['10/12', '13/14', '15/16']
                var totalData = this.value.data[0] //[100,100,100]
                var avgData = this.value.data[1] //[55,60,80]
                var series = []
                series.push(
                    {
                        name : '充电时长',
                        type : 'bar',
                        barWidth : 15,
                        itemStyle : {
                            color: {
                                type: 'linear',
                                x: 0,
                                y: 0,
                                x2: 1,
                                y2: 1,
                                colorStops: [{
                                    offset: 0, color: 'rgba(32,192,253, 1)' // 0% 处的颜色
                                }, {
                                    offset: 1, color: 'rgba(32,192,253, 0)' // 100% 处的颜色
                                }]
                            }
                        },
                        data : totalData,
                    },

                    {
                        name : '平均时长',
                        type : 'line',
                        smooth : true,
						symbol : 'none',
                        itemStyle : {
                            color: '#55f2ad'
                        },
                        data : avgData,
                    }

                )
				
                
                
                
				
				var options =  {
                    tooltip : {
                        show : true,
                        trigger: 'axis',
                    },
					grid : {
						top : '30px',
						right : '30px',
						bottom : '20px',
						left : '70px'
                    },
					
					
					xAxis: {
						type: 'category',
						axisLine : {
							lineStyle : {
								color : '#373f50'
							}
						},
						axisTick : {
							show : false
						},
						axisLabel : {
							show : true,
							color : '#a3a5a9'
						},
						data: xAxisData
					},
					yAxis: {
						type: 'value',
						axisLine : {
							lineStyle : {
								color : '#373f50'
							}
						},
						axisTick : {
							show : false
						},

						axisLabel : {
							show : true,
							color : '#a3a5a9'
						},

						splitLine : {
							show : true,
							lineStyle : {
								color : '#373f50'
							}
						}
					},
					
					series: series
				}

				return options
			}
		}
	}
</script>